package leetcode;


public class LeetCode55 {

    private boolean result = false;

    private int[] nums;

    //递归超出时间限制
    public boolean canJump1(int[] nums) {
        this.nums = nums;
        helper(0);
        return result;
    }

    private void helper(int index) {
        if (index == nums.length - 1)
            result = true;
        else if (index < nums.length - 1) {
            int maxJump = nums[index];
            for (int i = 1; i <= maxJump; i++) {
                helper(index + i);
            }
        }
    }

    public boolean canJump(int[] nums) {
        return result;
    }
//------------------------------------------------------------------
}
